package com.zensoft.oa.view;

import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.*;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: XieJihong
 * Date: 13-7-25
 * Time: 下午3:35
 * 导航工具条
 */
public class NavigatorView extends UI {

    private Navigator nav;
    CssLayout content = new CssLayout();
    CssLayout menu = new CssLayout();

    HashMap<String, Class<? extends View>> routes = new HashMap<String, Class<? extends View>>() {
        {
            put("/dashboard", View.class);
            put("/sales", View.class);
            put("/transactions", View.class);
            put("/reports", View.class);
            put("/schedule", View.class);
        }
    };

    HashMap<String, Button> viewNameToMenuButton = new HashMap<String, Button>();


    @Override
    protected void init(VaadinRequest vaadinRequest) {
        HorizontalLayout root = new HorizontalLayout();
        root.setSizeFull();
        addStyleName("main-view");
        setContent(root);

        VerticalLayout main = new VerticalLayout();
        main.addStyleName("sidebar");
        main.setWidth(null);
        main.setHeight("100%");

        CssLayout item = new CssLayout();
        addStyleName("branding");
        Label logo = new Label("<span>QuickTickets</span> Dashboard", ContentMode.HTML);
        logo.setSizeUndefined();
        item.addComponent(logo);
        main.addComponent(item);

        main.addComponent(menu);
        main.setExpandRatio(menu, 1);

        VerticalLayout userMenu = new VerticalLayout();
        userMenu.setSizeUndefined();
        addStyleName("user");

        Image profilePic = new Image(null, new ThemeResource("img/profile-pic.png"));
        profilePic.setWidth("34px");
        userMenu.addComponent(profilePic);

        Label userName = new Label("用户");
        userName.setSizeUndefined();
        userMenu.addComponent(userName);

        root.addComponent(main);



        //nav = new Navigator(this, content);
        //setContent(nav);


        for(String route : routes.keySet()){
            nav.addView(route, routes.get(route));
        }


    }

}
